package cn.aitrox.ry.service.anno.mq.produser;

import cn.aitrox.ry.service.anno.mq.bean.ScheduleMessagePostProcessor;
import cn.aitrox.ry.service.anno.mq.msg.FileHandlerMsg;
import cn.aitrox.ry.util.JSONUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.jms.core.JmsTemplate;
import org.springframework.stereotype.Component;

import javax.jms.Destination;

@Component
public class FileHandlerProduser {

    @Autowired
    @Qualifier("fileHandlerQueue")
    private Destination fileHandlerQueue;

    @Autowired
    private JmsTemplate jmsTemplate;

    public void send(Long fileHandlerInfoId) {
        jmsTemplate.convertAndSend(fileHandlerQueue, JSONUtil.toJson(new FileHandlerMsg(fileHandlerInfoId), FileHandlerMsg.class), new ScheduleMessagePostProcessor(30000));
    }
}
